jQuery(document).ready(function($) {

$('#id_user').blur(function(){
	$("#user_error").css("display","none");
	var username=$('#id_user').val();
	if(username.length>5){
		$.ajax({
			url: '/Accounts/UserCheck/',
			type: 'POST',
			dataType: 'json',
			data: {
				username:username
			},
			success:function(data){
				if(data.info==1){
					$("#user_remind").css("color","#d82424").css("display","inline");
					$("#user_remind").html("用户名已注册");
				}
				else{
					$("#user_remind").css("color","green").css("display","inline");
					$("#user_remind").html("合法用户名");
				}
			}
		});
	}
	else if(username.length!=0){
		$("#user_remind").css("color","#d82424").css("display","inline");
		$("#user_remind").html("用户名至少6位");
	}
	else{
		$("#user_remind").css("color","#d82424").css("display","inline");
		$("#user_remind").html("用户名不能为空");
	}
});

$('#id_pwd2').blur(function(){
	$("#pwd2_error").css("display","none");
	var pwd=$('#id_pwd').val();
	var pwd2=$('#id_pwd2').val();
	if(pwd!=pwd2){
		$("#pwd2_remind").css("display","inline");
		$("#pwd2_remind").html("二次输入密码不匹配");
	}
	else{
		$("#pwd2_remind").css("display","none")
	}
});

$('#id_pwd').blur(function(){
	$("#pwd_error").css("display","none");
	var pwd=$('#id_pwd').val();
	if(pwd===""){
		$("#pwd_remind").css("display","inline");
		$("#pwd_remind").html("密码不能为空");
	}
	else{
		$("#pwd_remind").css("display","none")
	}
});

$('#id_nickname').blur(function(){
	$("#nickname_error").css("display","none");
	var nickname=$('#id_nickname').val();
	if(nickname===""){
		$("#nickname_remind").css("display","inline");
		$("#nickname_remind").html("昵称不能为空");
	}
	else{
		$("#nickname_remind").css("display","none");
	}
});

$('#id_email').blur(function(){
	$("#email_error").css("display","none");
	var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	var email=$('#id_email').val();
	if(email===""){
		$("#email_remind").css("display","inline");
		$("#email_remind").html("电子邮箱不能为空");
	}
	else if(reg.test(email)){
		$.ajax({
			url:'/Accounts/EmailCheck/',
			type:'POST',
			dataType:'json',
			data:{
				email:email
			},
			success:function(data){
				if(data.info==1){
					$("#email_remind").css("display","inline");
					$("#email_remind").html("邮箱已注册");
				}
				else{
					$("#email_remind").css("display","none");
				}
			}
		});
	}
	else{
		$("#email_remind").css("display","inline");
		$("#email_remind").html("电子邮箱格式不正确");
	}
});

});
